/**
 * Licensee: andres orellana
 * License Type: Evaluation
 */
package ormsamples;

import org.orm.*;
public class RetrieveAndUpdatePinPassData {
	public void retrieveAndUpdateTestData() throws PersistentException {
		PersistentTransaction t = orm.PinPassPersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.CoordenadaDAO lormCoordenadaDAO = lDAOFactory.getCoordenadaDAO();
			orm.Coordenada lormCoordenada = lormCoordenadaDAO.loadCoordenadaByQuery(null, null);
			// Update the properties of the persistent object
			lormCoordenadaDAO.save(lormCoordenada);
			orm.dao.LogDAO lormLogDAO = lDAOFactory.getLogDAO();
			orm.Log lormLog = lormLogDAO.loadLogByQuery(null, null);
			// Update the properties of the persistent object
			lormLogDAO.save(lormLog);
			orm.dao.ClienteDAO lormClienteDAO = lDAOFactory.getClienteDAO();
			orm.Cliente lormCliente = lormClienteDAO.loadClienteByQuery(null, null);
			// Update the properties of the persistent object
			lormClienteDAO.save(lormCliente);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public void retrieveByCriteria() throws PersistentException {
		System.out.println("Retrieving Coordenada by CoordenadaCriteria");
		orm.CoordenadaCriteria coordenadaCriteria = new orm.CoordenadaCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//coordenadaCriteria.id.eq();
		System.out.println(coordenadaCriteria.uniqueCoordenada());
		
		System.out.println("Retrieving Log by LogCriteria");
		orm.LogCriteria logCriteria = new orm.LogCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//logCriteria.log_id.eq();
		System.out.println(logCriteria.uniqueLog());
		
		System.out.println("Retrieving Cliente by ClienteCriteria");
		orm.ClienteCriteria clienteCriteria = new orm.ClienteCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//clienteCriteria.cli_id.eq();
		System.out.println(clienteCriteria.uniqueCliente());
		
	}
	
	
	public static void main(String[] args) {
		try {
			RetrieveAndUpdatePinPassData retrieveAndUpdatePinPassData = new RetrieveAndUpdatePinPassData();
			try {
				retrieveAndUpdatePinPassData.retrieveAndUpdateTestData();
				//retrieveAndUpdatePinPassData.retrieveByCriteria();
			}
			finally {
				orm.PinPassPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
